import net.spy.memcached.MemcachedClient;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Map;

/**
 * Memcached Command Test Coverage
 */
public class Test {

    public static void main(String[] args) throws IOException, InterruptedException {
        MemcachedClient c = new MemcachedClient(new InetSocketAddress("localhost", 11211));
        c.set("k1", 3600, "v1");
        c.set("k2", 3600, "v2");
        System.out.println("[" + c.get("k1").equals("v1") + "]set");
        System.out.println("[" + c.get("k1").equals("v1") + "]get");
        Map<String, Object> map = c.getBulk(new String[]{"k1", "k2"});
        System.out.println("[" + (map.get("k1").equals("v1") && map.get("k2").equals("v2")) + "]gets");
        c.add("k2", 3600, "v3");
        c.add("k3", 3600, "v3");
        System.out.println("[" + ((!c.get("k2").equals("v3")) && c.get("k3").equals("v3")) + "]add");
        c.replace("k3", 3600, "v4");
        c.replace("k4", 3600, "v4");
        System.out.println("[" + (c.get("k3").equals("v4") && c.get("k4") == null) + "]replace");
        c.delete("k3");
        System.out.println("[" + (c.get("k3") == null) + "]delete");
        c.set("k5", 3600, "v5");
        System.out.println("[" + ((c.incr("k5", 10) == 10) && (c.incr("k6", 10) == -1)) + "]incr");
        System.out.println("[" + ((c.decr("k5", 5) == 5) && (c.decr("k6", 5) == -1) && (c.decr("k5", 6) == 0)) + "]decr");
        c.flush();
        System.out.println("[" + ((c.get("k1") == null) && (c.get("k2") == null)) + "]flush_all");
        System.out.println(c.getVersions());
        c.shutdown();
    }
}
